home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / system / idcutils.zip / LETTER.ASM < prev    next >
Assembly Source File  |  1988-12-12  |  14KB  |  570 lines

  1.  
  2. ;================================================================
  3. ;Program    : LETTER.ASM                    |
  4. ;Author        : Gary Conway                    |
  5. ;Created    : 09.08.88                    |
  6. ;Update        : 12.11.88                    |
  7. ;Version    : 1.1                        |
  8. ;Notice        : Copyright 1988 Infinity Design Concepts    |
  9. ;          Inc. all rights reserved            |
  10. ;          1052 Parkway Drive                |
  11. ;          Louisville, Kentucky 40217            |
  12. ;          502-636-1234                    |
  13. ;================================================================
  14.  
  15. comment    |
  16.  
  17.     This source code is copyrighted material and may not be used
  18.     or reproduced for financial gain without the expressed written
  19.     consent of the author.
  20.  
  21.     |
  22.  
  23.  
  24. ; this program will print addresses on envelopes on the HP Laserjet series ][
  25. ; or brother HL-8 laser printers in landscape mode. The envelope will be
  26. ; inserted in the manual feed tray
  27. ; NOTE: The original source code is set for business envelopes, if you have
  28. ;       another size envelope that you wish to use, then you must change
  29. ;     this file and assemble it again. You will have to change the
  30. ;    TopMargin and LeftMargin variables.
  31.  
  32.  
  33. comment    |
  34.  
  35. ; ASSEMBLE with the following commands.
  36.  
  37.     masm letter;
  38.     link letter;
  39.     
  40.     |
  41.  
  42.  
  43. MajVer        Equ    "1"
  44. MinVer        Equ    "0"
  45.  
  46. ; define a macro for positioning the cursor on the screen
  47.  
  48. CURPOS    Macro    ROW,COL,PAGE    ;;macro to set cursor to desired screen pos.
  49.     Mov    DH,ROW
  50.     Mov    DL,COL
  51.     Mov    BH,PAGE
  52.     Mov    AH,2
  53.     Int    10H        ;; use BIOS routine (slow)
  54.     Endm
  55.  
  56.  
  57.  
  58. DSEG        Segment para public 'DATA'
  59.  
  60. CR        Equ    13        ; CR may now be used instead of 13
  61. LF        Equ    10        ; LF "    "  "   "    "       " 10
  62. ESCchar        Equ    27        ; ESC (ESCape) character
  63.  
  64.  
  65. ; define some variables for the built-in routines
  66.  
  67. CurShape    DW    ?        ; save shape of cursor when pgm. called
  68. Bksp_        DB    8,' ',8,0
  69. CONSBUFF    DB     100,00,100 DUP (' ')
  70.  
  71. Print_String    Label Byte
  72.  
  73. ;        DB    1Bh,0Dh,"H"    ; set to emulate HP laserjet+
  74.                     ;    (used ONLY on brother HL-8)
  75.         DB    1Bh,"&l3H"    ; set for envelopes
  76.         DB    1Bh,"&l1O"    ; set to landscape mode
  77.         DB    0        ; terminator
  78. Reset        DB    1Bh,"E",0    ; reset printer string
  79.  
  80. Control_C    DB    "Control-C to abort",cr,lf
  81.         DB    15 dup(" ")
  82.         DB    "If you find this program useful, please register!",0
  83.  
  84. SignOn        DB    "Ver. ",MajVer,".",MinVer," "
  85.         DB    "Copyright 1988, Infinity Design Concepts, Inc. all rights reserved",cr,lf,lf
  86.         DB    3 dup(" ")
  87.         DB    "This program will print envelopes on the"
  88.         DB    " HP LaserJet+ or compatible printer.",cr,lf
  89.         DB    9 dup(" ")
  90.         DB    "Note that the envelopes will be fed thru the manual tray",cr,lf
  91.         DB    20 dup(" ")
  92.         DB    "and printed in the LandScape mode."
  93.         DB    cr,lf,lf,lf,0
  94.  
  95. NotReady    DB    cr,lf,7,"Printer Not Ready... Hit ENTER.",7,cr,lf,0
  96. Blanks        DB    "                                       ",0
  97.  
  98. ; the prompts
  99.  
  100. Name1        DB    "Enter Name ..................: ",0
  101. Add1        DB    "Enter First Line of Address .: ",0
  102. Add2        DB    "Enter Second Line of Address : ",0
  103. City        DB    "Enter City ..................: ",0
  104. State        DB    "Enter State .................: ",0
  105. Zip        DB    "Enter Zip ...................: ",0
  106. Attn        DB    "Enter Attn of Name ..........: ",0
  107.  
  108. ; the following information is what is actually printed
  109.  
  110. Pr_name        DB    50 dup(0)
  111. Pr_add1        DB    50 dup(0)
  112. Pr_add2        DB    50 dup(0)
  113. Pr_City        DB    50 dup(0)
  114. Pr_State    DB    50 dup(0)
  115. Pr_Zip        DB    50 dup(0)
  116. Attn_Pr        DB    "Attn: "
  117. Pr_Attn        DB    50 dup(0)
  118.  
  119. DSEG        Ends
  120.  
  121.  
  122.  
  123. ; define the CODE segment
  124.  
  125. CSEG        Segment para public 'CODE'
  126.         ASSUME CS:CSEG,SS:ASTACK
  127.  
  128. ENTPT        Proc                ;Start of Code Execution
  129.         Mov    AX,DSEG         ; set up segment addresses
  130.         Mov    DS,AX            ; data seg.
  131.         Mov    ES,AX            ; extra seg.
  132.         ASSUME    DS:DSEG,ES:DSEG
  133.  
  134.         Call    SaveCursor        ; save cursor shape
  135.         Call    Clrsc            ; clear the screen
  136.         Call    Curoff            ; turn cursor off
  137.  
  138.         CurPos    1,0,0
  139.         Lea    SI,SignOn
  140.         Call    Ilprt            ; print signon message
  141.  
  142.         CurPos    18,31,0            ; put cursor at 18,31
  143.         Lea    SI,Control_C
  144.         Call    Ilprt            ; print abort msg.
  145.         
  146.         CurPos    9,0,0            ; put cursor at 9,0
  147.         Call    Curon            ; turn cursor back on
  148. ; get name
  149.         Lea    SI,Name1
  150.         Call    Ilprt            ; print name prompt
  151.         Call    Rdcons            ; get string from user
  152.         Lea    SI,Consbuff +2
  153.         Lea    DI,Pr_name        ; destination for printing
  154.         Call    Insert            ; put user string there
  155.         Call    Crlf            ; send crlf to screen
  156.  
  157. ; get address line 1
  158.  
  159.         Lea    SI,Add1
  160.         Call    Ilprt            ; print addr.line 1 prompt
  161.         Call    Rdcons            ; get string from user
  162.         Lea    SI,Consbuff +2
  163.         Lea    DI,Pr_add1
  164.         Call    Insert            ; store it
  165.         Call    Crlf
  166.  
  167. ; get address line 2
  168.  
  169.         Lea    SI,Add2
  170.         Call    Ilprt
  171.         Call    Rdcons
  172.         Lea    SI,Consbuff +2
  173.         Lea    DI,Pr_add2
  174.         Call    Insert
  175.         Call    Crlf
  176.  
  177. ; get city
  178.         Lea    SI,City
  179.         Call    Ilprt
  180.         Call    Rdcons
  181.         Lea    SI,Consbuff +2
  182.         Lea    DI,Pr_city
  183.         Call    Insert
  184.         Call    Crlf
  185. ; get state
  186.  
  187.         Lea    SI,State
  188.         Call    Ilprt
  189.         Call    Rdcons
  190.         Lea    SI,Consbuff +2
  191.         Lea    DI,Pr_state
  192.         Call    Insert
  193.         Call    Crlf
  194. ; get zip
  195.         Lea    SI,Zip
  196.         Call    Ilprt
  197.         Call    Rdcons
  198.         Lea    SI,Consbuff +2
  199.         Lea    DI,Pr_zip
  200.         Call    Insert
  201.         Call    Crlf
  202. ; get attn of
  203.         Lea    SI,Attn
  204.         Call    Ilprt
  205.         Call    Rdcons
  206.         Lea    SI,Consbuff +2
  207.         Lea    DI,Pr_attn
  208.         Call    Insert
  209.  
  210. Test_Ptr:    Mov    AH,2
  211.         Xor    DX,DX
  212.         Int    17h        ; read printer status
  213.         Test    AH,01001001b    ; bit 7 = busy
  214.                     ; bit 5 = out of paper
  215.                     ; bit 3 = I/O error
  216.                     ; bit 0 = time out
  217.         Jz    Ptr_Ready
  218.         CurPos    20,0,0
  219.         Lea    SI,NotReady
  220.         Call    Ilprt
  221.         Mov    AH,8
  222.         Int    21h        ; wait for character and test again
  223.         Jmp    Short Test_Ptr
  224.  
  225. Ptr_Ready:    CurPos    20,0,0
  226.         Lea    SI,Blanks
  227.         Call    Ilprt            ; remove error msg if there
  228.  
  229.         Lea    SI,Print_String
  230.         Call    Print            ; set printer to proper mode
  231.         Call    Print_CRs        ; print 20 crlf's
  232.         Call    Print_Env        ; print the envelope
  233.         Call    Pcrlf            ; carriage return linefeed
  234.         Mov    AL,12
  235.         Call    Prchar            ; send forfeed
  236.         Lea    SI,Reset
  237.         Call    Print            ; reset printer to control
  238.                         ; panel defaults
  239. Exit:        CurPos    20,0,0            ; put cursor at 20,0
  240.         Call    Curon            ; turn cursor on
  241.         Mov    AX,4C00h        ; return to DOS
  242.         Int    21h
  243.  
  244. ;--------------------------------------------------------------------------
  245. ;            SUPPORT ROUTINES
  246. ;--------------------------------------------------------------------------
  247.  
  248.  
  249.  
  250. ;------------------------------------------------------------------
  251. ; THIS ROUTINE DETERMINES WHERE THE TEXT ON THE ENVELOPE WILL START
  252. ; AS MEASURED FROM THE TOP OF THE ENVELOPE
  253. ; If you wish to change this distance, change TopMargin below to
  254. ; whatever works for you
  255. ; send 20 carriage return and linefeeds to the printer
  256. ;------------------------------------------------------------------
  257.  
  258. TopMargin    Equ    20
  259.  
  260. Print_CRs    Proc
  261.         Mov    CX,TopMargin    ; send this many crlf's
  262. Pr_1:        Push    CX
  263.         Call    Pcrlf
  264.         Pop    CX
  265.     Loop    Pr_1
  266.         Ret
  267. Print_CRs    Endp
  268.  
  269. ;------------------------------------------------------------------
  270. ; THIS ROUTINE DETERMINES WHERE THE TEXT ON THE ENVELOPE WILL START
  271. ; AS MEASURED FROM THE LEFT MARGIN. If you wish to change this
  272. ; distance, change LeftMargin below.
  273. ; send 37 spaces to the printer
  274. ;-------------------------------------------------------------------
  275.  
  276. LeftMargin    Equ    37            ; left margin
  277.  
  278. Print_Space    Proc
  279.         Mov    CX,LeftMargin        ; this many spaces
  280. Pr_Sp:        Push    CX            ; save it
  281.         Mov    AL," "
  282.         Call    Prchar            ; send space to printer
  283.         Pop    CX
  284.     Loop    Pr_Sp                ; loop till done
  285.         Ret
  286. Print_Space    Endp
  287.  
  288.  
  289. ;---------------------------------------
  290. ; this procedure will print the envelope
  291. ;---------------------------------------
  292.  
  293. Print_Env    Proc
  294.         Call    Print_Space        ; print 37 spaces
  295.         Lea    SI,PR_name        ; point to name string
  296.         Cmp    Byte Ptr[SI],0        ; empty ?
  297.         Je    Empt_1            ; yup, skip it
  298.         Call    Print            ; else, print the string
  299.         Call    Pcrlf            ; and a crlf
  300.         Call    Print_Space        ; print 37 spaces
  301.  
  302. ; print address line 1
  303.  
  304. Empt_1:        Lea    SI,Pr_add1        ; point to addr line 1 string
  305.         Cmp    Byte Ptr [SI],0        ; empty ?
  306.         Je    Empt_2            ; yup, skip it
  307.         Call    Print            ; else print it
  308.         Call    Pcrlf            ; and a crlf
  309.         Call    Print_Space        ; print 37 spaces
  310.  
  311. ; print address line 2, if not empty
  312.  
  313. Empt_2:        Lea    SI,Pr_add2        ; point to addr line 2 string
  314.         Cmp    byte Ptr [SI],0        ; string empty ?
  315.         Je    Empt_3            ; yup, skip it
  316.         Call    Print            ; else, print it
  317.         Call    Pcrlf            ; and a crlf
  318.         Call    Print_Space        ; print 37 spaces
  319.  
  320. ; print city,state, zip
  321.  
  322. Empt_3:        Lea    SI,Pr_city